<?php 
function deleteAll($directory, $empty = false) { 
    if(substr($directory,-1) == "/") { 
        $directory = substr($directory,0,-1); 
    } 
	if(!is_dir($directory)){
		echo "It's a file<br>";
		unlink($directory);
	}
    if(!file_exists($directory) || !is_dir($directory)) { 
    	echo "File not Exist $directory<br>";
        return false; 
    } elseif(!is_readable($directory)) { 
    	echo "Directory not readeable $directory<br>";
        return false; 
    } else { 
        $directoryHandle = opendir($directory); 
        
        while ($contents = readdir($directoryHandle)) { 
            if($contents != '.' && $contents != '..') { 
                $path = $directory . "/" . $contents; 
                
                if(is_dir($path)) { 
                    deleteAll($path); 
                } else { 
                    unlink($path); 
                } 
            } 
        } 
        
        closedir($directoryHandle); 

        if($empty == false) { 
            if(!rmdir($directory)) {
            	echo "Cant rmdir $directory<br>"; 
                return false; 
            } 
        } 
        
        return true; 
    } 
}
switch($_SERVER['HTTP_HOST']) {
    case 'e-dsl':
        $dir = 'C:\workspace\sfprojects\e-dsl';
        break;
    default:
        $dir = '/appli/projects/uoi/apache_2.2.11/htdocs/doidfedsl/e-dsl/';
        break;        
}
echo "<h1>Borrando $dir</h1>";
$var = deleteAll($dir);
if($var){
	echo ":o)!";
} else{
	echo ":o(((((!";
}

?> 

